package com.weitu.permission.departmentDuty.service.impl;

import com.weitu.permission.departmentDuty.mapper.DepartmentDutyMapper;
import com.weitu.permission.departmentDuty.service.DepartmentDutyService;
import com.weitu.permission.duty.entity.Duty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class DepartmentDutyServiceImpl implements DepartmentDutyService {

    private final DepartmentDutyMapper departmentDutyMapper;

    @Autowired
    public DepartmentDutyServiceImpl(DepartmentDutyMapper departmentDutyMapper) {
        this.departmentDutyMapper = departmentDutyMapper;
    }


    @Override
    public List<Duty> findByParam(Map paramMap) {
        return departmentDutyMapper.findByParam(paramMap);
    }

    @Transactional
    @Override
    public Integer add(List<Map> list) {
        return departmentDutyMapper.add(list);
    }

    @Transactional
    @Override
    public Integer add(List<Map> list, String deptId) {
        Integer result = 0;
        result += departmentDutyMapper.delete(deptId);
        result += departmentDutyMapper.add(list);
        return result;
    }

    @Transactional
    @Override
    public Integer delete(String deptId) {
        return departmentDutyMapper.delete(deptId);
    }
}
